package com.taxinfo.service.impl.data;

import com.taxinfo.common.ClientSession;
import com.taxinfo.pojo.dto.AccBalMapInfoDto;
import com.taxinfo.pojo.dto.AssetAndLibDto;
import com.taxinfo.pojo.dto.IncomeStmInfoDto;
import com.taxinfo.pojo.dto.LoginDto;
import com.taxinfo.service.impl.MainReportServiceImpl;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 企业所得税月（季）度预缴纳税申报表（A类）.xlsx处理(季度）
 * @author wanghy
 */
public class QuartEntIncomeTaxPrepaidTaxDecMonth extends CommFunction implements MainReportServiceImpl.ExcelUpdateInterface {

    /**
     *
     * @param wb workbook
     * @param accBalMapInfos 映射的数据集合
     * @param type 类型 :年度、季度、月度
     */
    @Override
    public String businessLogic(XSSFWorkbook wb, Map<String,List> dataInfos, String sblx, String sbYear) {
        //1.填充企业所得税月（季）度预缴纳税申报表（A类）
        Sheet sheetA100000 = wb.getSheet("企业所得税月（季）度预缴纳税申报表（A类）");

        LoginDto loginDto =(LoginDto) ClientSession.getAttribute("user");
        //所属期处理
        String[] ssq= super.getSsqInfo(sblx,sbYear);
        sheetA100000.getRow(2).getCell(6).setCellValue(getString(loginDto.getCreditCode(),"0"));
        sheetA100000.getRow(3).getCell(10).setCellValue(getString(loginDto.getCompanyName(),"0"));
        sheetA100000.getRow(1).getCell(0).setCellValue("税款所属期间： ".concat(getString(ssq[0],"0")).concat("至").concat(getString(ssq[1],"0")));
        this.fillCellsA100000Column(dataInfos,sheetA100000,17);

//        //2.填充附表1
//        Sheet sheetA101010 = wb.getSheet("附表1");
//        this.fillCellsA101010Column(dataInfos,sheetA101010,2);
//
//        //3.附表2
//        Sheet sheetA1010120 = wb.getSheet("附表2");
//        this.fillCellsA1010120Column(dataInfos,sheetA1010120,2);
//
//        //3.附表3
//        Sheet sheetA101030 = wb.getSheet("附表3");
//        this.fillCellsA101030Column(dataInfos,sheetA101030,2);
        return "";
    }

    /**
     *
     * @param standardSubMap
     * @param sheet
     * @param i
     */
    private void fillCellsA100000Column(Map<String,List> dataInfos, Sheet sheet, int columnIndex) {
        List<AccBalMapInfoDto> accBalMapInfos = dataInfos.get("accBalMapInfos");
        List<IncomeStmInfoDto>  incomMapInfos = dataInfos.get("incomMapInfos");
        List<IncomeStmInfoDto> lastIncomeDataInfo = dataInfos.get("lastIncomeDataInfo");
        Map<String, AccBalMapInfoDto> standardSubMap = accBalMapInfos.stream().collect(Collectors.toMap(AccBalMapInfoDto::getSubName, accBalMapInfoDto -> accBalMapInfoDto));
        Map<String, IncomeStmInfoDto> incomMap = incomMapInfos.stream().collect(Collectors.toMap(IncomeStmInfoDto::getSubName, incomeStmInfoDto -> incomeStmInfoDto));

        //SY01	一、营业收入
        IncomeStmInfoDto data1 =  incomMap.get("一、营业收入");
        if (null != data1){
            sheet.getRow(20).getCell(columnIndex).setCellValue(getAmtDecimal(data1.getCurrentAmt()).doubleValue());
        }

        //SY02	减：营业成本
        IncomeStmInfoDto data2 =  incomMap.get("减：营业成本");
        if (null != data2){
            sheet.getRow(21).getCell(columnIndex).setCellValue(getAmtDecimal(data2.getCurrentAmt()).doubleValue());
        }

        //SY02	减：营业成本
        IncomeStmInfoDto data3 =  incomMap.get("利润总额");
        if (null != data3){
            sheet.getRow(22).getCell(columnIndex).setCellValue(getAmtDecimal(data3.getCurrentAmt()).doubleValue());
        }

    }

    /**
     * 附表1
     * @param standardSubMap
     * @param sheet
     * @param i
     */
    private void fillCellsA101010Column(Map<String,List> dataInfos, Sheet sheet, int columnIndex) {
    }

    /**
     * 附表2
     * @param standardSubMap
     * @param sheet
     * @param i
     */
    private void fillCellsA1010120Column(Map<String,List> dataInfos, Sheet sheet, int columnIndex) {
    }

    /**
     * 附表3
     * @param standardSubMap
     * @param sheet
     * @param i
     */
    private void fillCellsA101030Column(Map<String,List> dataInfos, Sheet sheet, int columnIndex) {
    }

}
